Skip to content

feat(sql): add SQLite update hook support#3225

Open
TobiasGrothmann wants to merge 1 commit intotauri-apps:v2from
TobiasGrothmann:feat/sqlite-update-hook
Open

feat(sql): add SQLite update hook support#3225
TobiasGrothmann wants to merge 1 commit intotauri-apps:v2from
TobiasGrothmann:feat/sqlite-update-hook

Conversation

@TobiasGrothmann
Copy link
Copy Markdown

@TobiasGrothmann TobiasGrothmann commented Jan 20, 2026

This adds support for the sqlite update hook and fixes #3177

I'm using it like so:


capabilities/default.json

[...]
"permissions": [
   [...],
    "sql:allow-setup-update-hook",
    "sql:allow-remove-update-hook",
]

updateHookTauri.ts

import { invoke } from "@tauri-apps/api/core"
import { listen, UnlistenFn } from "@tauri-apps/api/event"

export interface UpdateHookEvent {
  operation: "INSERT" | "UPDATE" | "DELETE" | "UNKNOWN"
  database: string
  table: string
  rowid: number
}

export type UpdateHookCallback = (event: UpdateHookEvent) => void

let unlisten: UnlistenFn | null = null

export async function setupUpdateHook(
  dbPath: string,
  callback: UpdateHookCallback,
): Promise<void> {
  if (unlisten) {
    await removeUpdateHook(dbPath)
  }

  unlisten = await listen<UpdateHookEvent>("sqlite-update-hook", (event) => {
    callback(event.payload)
  })

  try {
    await invoke("plugin:sql|setup_update_hook", { db: dbPath })
  } catch (error) {
    console.error("Failed to setup update hook:", error)
    unlisten()
    unlisten = null
    throw error
  }
}

export async function removeUpdateHook(dbPath: string): Promise<void> {
  if (unlisten) {
    unlisten()
    unlisten = null
  }

  try {
    await invoke("plugin:sql|remove_update_hook", { db: dbPath })
  } catch (error) {
    console.error("Failed to remove update hook:", error)
    throw error
  }
}

@TobiasGrothmann TobiasGrothmann requested a review from a team as a code owner January 20, 2026 15:37
@github-actions
Copy link
Copy Markdown
Contributor

Package Changes Through a18d4f2

There are 6 changes which include updater with minor, updater-js with minor, barcode-scanner with patch, barcode-scanner-js with patch, sql with patch, sql-js with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
api-example 2.0.40 2.0.41
api-example-js 2.0.36 2.0.37
barcode-scanner 2.4.3 2.4.4
barcode-scanner-js 2.4.3 2.4.4
sql 2.3.1 2.3.2
sql-js 2.3.1 2.3.2
updater 2.9.0 2.10.0
updater-js 2.9.0 2.10.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expo sqlite update_hook

2 participants